package selef.xiafan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import selef.xiafan.dto.CommentDTO;
import selef.xiafan.entity.order.Order;
import selef.xiafan.service.ICommentService;
import selef.xiafan.util.result.Result;
import selef.xiafan.util.result.ResultFactory;

/**
 * @author xiafan
 * @version 1.0
 * @date 2021/9/26 11:39
 */
@RestController
@RequestMapping("/api/comment")
public class CommentController {
    @Autowired
    ICommentService iCommentService;

    @PostMapping("/add")
    public Result add(@RequestBody CommentDTO commentDTO){
        iCommentService.add(commentDTO);
        return ResultFactory.buildSuccessResult("评论成功");
    }

    @PostMapping("/findComment")
    public Result findComment(@RequestBody Order order){
        Object object = iCommentService.findComment(order);
        return ResultFactory.buildSuccessResult(object);
    }
}
